<script type="text/javascript"><!-- hide from old browsers
// turn on/off any "other"fields
function fb_other_on (othername) {
    var box = document.getElementById(othername);
    box.removeAttribute('disabled');
}

function fb_other_off (othername) {
    var box = document.getElementById(othername);
    box.setAttribute('disabled', 'disabled');
}

function validate (form) {
    var alertstr = '';
    var invalid  = 0;
    var invalid_fields = new Array();

    // favorite_color: radio group or multiple checkboxes
    var favorite_color = null;
    var selected_favorite_color = 0;
    for (var loop = 0; loop < form.elements['favorite_color'].length; loop++) {
        if (form.elements['favorite_color'][loop].checked) {
            favorite_color = form.elements['favorite_color'][loop].value;
            selected_favorite_color++;
            if (favorite_color == '_other_favorite_color') favorite_color = form.elements['_other_favorite_color'].value;
            if (favorite_color != null && favorite_color != "" && ! favorite_color.match(/^[a-zA-Z]+$/)) {
                alertstr += '- Invalid entry for the "Favorite Color" field\n';
                invalid++;
                invalid_fields.push('favorite_color');
            }
        } // if
    } // for favorite_color

    if (invalid > 0 || alertstr != '') {
        if (! invalid) invalid = 'The following';   // catch for programmer error
        alert(''+invalid+' error(s) were encountered with your submission:'+'\n\n'
                +alertstr+'\n'+'Please correct these fields and try again.');
        return false;
    }
    return true;  // all checked ok
}
//-->
</script>
<noscript><font color="#cc0000"><b>Please enable Javascript or use a newer browser.</b></font></noscript>
<form action="TEST" method="get" onsubmit="return validate(this);">
<div><input id="_submitted" name="_submitted" type="hidden" value="1" /></div>
<table>
<tr valign="top">
  <td>Favorite Color</td>
  <td><table>
  <tr>
    <td><input id="favorite_color_red" name="favorite_color" onclick="fb_other_off('_other_favorite_color')" type="radio" value="red" /></td>
    <td><label for="favorite_color_red">red</label></td>
  </tr>
  <tr>
    <td><input id="favorite_color_green" name="favorite_color" onclick="fb_other_off('_other_favorite_color')" type="radio" value="green" /></td>
    <td><label for="favorite_color_green">green</label></td>
  </tr>
  <tr>
    <td><input id="favorite_color_blue" name="favorite_color" onclick="fb_other_off('_other_favorite_color')" type="radio" value="blue" /></td>
    <td><label for="favorite_color_blue">blue</label></td>
  </tr>
  <tr>
    <td><input id="favorite_color_yellow" name="favorite_color" onclick="fb_other_off('_other_favorite_color')" type="radio" value="yellow" /></td>
    <td><label for="favorite_color_yellow">yellow</label></td>
  </tr>
  <tr>
    <td><input id="_favorite_color" name="favorite_color" onclick="fb_other_on('_other_favorite_color')" type="radio" value="_other_favorite_color" /></td>
    <td><label for="_favorite_color">Other:</label></td>
  </tr>
  </table> <input disabled="disabled" id="_other_favorite_color" name="_other_favorite_color" type="text" /></td>
</tr>
<tr valign="top">
  <td align="center" colspan="2"><input id="_submit" name="_submit" type="submit" value="Submit" /></td>
</tr>
</table>
</form>
